package com.zjh;

import com.zjh.bean.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;

/**
 * @author LiZiQiu
 * @data 2023/3/4
 */
public class Test4 {
    public static void main(String[] args) {
        try {
            Reader reader=Resources.getResourceAsReader("mybatis-config.xml");
            SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
            SqlSessionFactory build = builder.build(reader);
            SqlSession session = build.openSession();
            HashMap map = new HashMap();
            map.put("id",6);
            map.put("sno","stu006");
            map.put("sname","兰兰");
            int insert = session.insert("com.zjh.dao.StudentDao.insertStudent2",map);
            session.commit();
            System.out.println(insert);
            session.close();
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }





    }
}
